package com.cnhis.cloudhealth.clinical.hosnurse.hosmodifypatient.bo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cnhis.cloudhealth.clinical.hosnurse.hosmodifypatient.dao.HosModifyPatientDao;
import com.cnhis.cloudhealth.clinical.hosnurse.hosparams.bo.HosParamsBo;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.utils.JsonUtil;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

@Service
public class HosModifyPatientBo {
  @Resource
  private HosModifyPatientDao hosModifyPatientDao;
  @Resource
  private HosParamsBo hosParamsBo;
  public ModelVo querySafetyMechanism()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.querySafetyMechanism();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	  
  }
  public ModelVo getPatientType()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getPatientType();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo stayAim()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.stayAim();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo queryClinicalDoctor()throws Exception{
	  ModelVo mo = new ModelVo();
			List list =null;
			try {
				list=hosModifyPatientDao.queryClinicalDoctor();
				
			} catch (Exception e) {
				e.printStackTrace();
				mo.setResult(StaticKeys.OH_FALSE);
				return mo;
			}
			mo.setList(list);
			mo.setResult(StaticKeys.OH_SUCCESS);
			mo.setRows(list);
			return mo;
  }
  public ModelVo getSettingColumn()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getSettingColumn();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	  
  }
  public ModelVo getDefaultProperty()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getDefaultProperty();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo getPay()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getPay();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo getEnterHospitalDisease()throws Exception{
	  
	  ModelVo mo = new ModelVo();
			List list =null;
			try {
				list=hosModifyPatientDao.getEnterHospitalDisease();
				
			} catch (Exception e) {
				e.printStackTrace();
				mo.setResult(StaticKeys.OH_FALSE);
				return mo;
			}
			mo.setList(list);
			mo.setResult(StaticKeys.OH_SUCCESS);
			mo.setRows(list);
			return mo;
	  
  }
  public ModelVo enterhospitalWay()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.enterhospitalWay();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	  
  }
  public ModelVo getSingelParamValue(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getSingelParamValue(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
	  
  }
  public ModelVo getBranchedOrg(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getBranchedOrg(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo getMedicareType(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getMedicareType(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo execSavedOneUserParameters(Map map)throws Exception{
	  ModelVo vo = new ModelVo(StaticKeys.OH_SUCCESS);
	  String params = map.get("params").toString();
	  List<Map<String,Object>> parasList = JsonUtil.getList(params);
	  for (Map<String, Object> map2 : parasList) {
		   Map hs = new HashMap();
		   hs.put("ProductID", Integer.parseInt(map2.get("productid").toString()));
		   hs.put("ProgramID", Integer.parseInt(map2.get("programid").toString()));
		   hs.put("ParamNo", Integer.parseInt(map2.get("paramno").toString()));
		   hs.put("UserID", Long.parseLong(map.get("UserID").toString()));
		   hs.put("PName", map2.get("pname").toString());
		   hs.put("PValue", map2.get("pvalue").toString());
		   hs.put("PDescrip", map2.get("pdescrip").toString());
		   hs.put("Privilege", map2.get("privilege").toString());
		   hosParamsBo.savedOneUserParameters(hs);
	   }
	  
	  return vo;
	  
  }
  public ModelVo getMedicareDiseaseName(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getMedicareDiseaseName(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo getDegree()throws Exception{
	  ModelVo mo = new ModelVo();
			List list =null;
			try {
				list=hosModifyPatientDao.getDegree();
				
			} catch (Exception e) {
				e.printStackTrace();
				mo.setResult(StaticKeys.OH_FALSE);
				return mo;
			}
			mo.setList(list);
			mo.setResult(StaticKeys.OH_SUCCESS);
			mo.setRows(list);
			return mo;
  }
  public ModelVo getIdentity()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getIdentity();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo clinDiagnose(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.clinDiagnose(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
  public ModelVo enterHospitalTreatment()throws Exception{
	  ModelVo mo = new ModelVo();
			List list =null;
			try {
				list=hosModifyPatientDao.enterHospitalTreatment();
				
			} catch (Exception e) {
				e.printStackTrace();
				mo.setResult(StaticKeys.OH_FALSE);
				return mo;
			}
			mo.setList(list);
			mo.setResult(StaticKeys.OH_SUCCESS);
			mo.setRows(list);
			return mo;
  }
  public ModelVo getWay()throws Exception{
	  ModelVo mo = new ModelVo();
		List list =null;
		try {
			list=hosModifyPatientDao.getWay();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(list);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(list);
		return mo;
  }
}
